import { message } from "antd";
import axios from "axios";
import React from "react";
import { Button, Input, Form } from "react-vant";
import {useNavigate} from 'react-router-dom'
const Index: React.FC = () => {
  const [form] = Form.useForm();
  const navigate=useNavigate()
  const onFinish = (values: any) => {
    axios.put('/api/add',values).then((resp)=>{
        let {code,msg}=resp.data
        if (code==200) {
            message.success(msg)
            navigate(-1)
        }
    })
  };
  return (
    <div>
      <Form
        form={form}
        onFinish={onFinish}
        footer={
          <div style={{ margin: "16px 16px 0" }}>
            <Button round nativeType="submit" type="primary" block>
              提交
            </Button>
          </div>
        }
      >
        <Form.Item
          rules={[{ message: "请填写病症" }]}
          name="word"
          label="病症"
        >
          <Input placeholder="请输入病症" />
        </Form.Item>
      </Form>
    </div>
  );
};
export default Index;
